#include "data_struct/base/TimeWorkBase/ModuleBase.h"
#include "modules/AssistModule/LogModule.h"

namespace behavior_controller
{
    void ModuleBase::Install()
    {
        InstallModule();
        is_installed_ = true;
    }

    void ModuleBase::Uninstall()
    {
        PrepareRemove();
        is_installed_ = false;
    }

    void ModuleBase::Start() { StartModule(); }

    void ClonerBase::PrepareRemove()
    {
        Clear();
        if (work_thread_ptr_)
        {
            work_thread_ptr_->interrupt();
            work_thread_ptr_->join();
        }
    }

    void ClonerBase::InstallModule() { Initialize(); }

    void ClonerBase::StartModule()
    {
        work_thread_ptr_ = std::make_shared<boost::thread>(
            boost::bind(&ClonerBase::Work, this));
        LogPub::Debug("behavior_controller", "Create thread:", work_thread_ptr_->get_id());
    }

} // namespace behavior_controller